<div class="container">
  <section>
    <h2>
      员工添加
    </h2>
    <form class="form" name="form" ng-submit="register(form)" novalidate>

      <div class="form-group" ng-class="{ 'has-success': form.name.$valid && submitted,
                                          'has-error': form.name.$invalid && submitted }">
        <label>姓名</label>

        <input type="text" name="name" class="form-control" ng-model="user.name"
               required/>
        <p class="help-block" ng-show="form.name.$error.required && submitted">
          姓名为必填内容
        </p>
      </div>

      <div class="form-group" ng-class="{ 'has-success': form.phone.$valid && submitted,
                                          'has-error': form.phone.$invalid && submitted }">
        <label>电话</label>

        <input type="text" name="phone" class="form-control" ng-model="user.phone"
               required/>
        <p class="help-block" ng-show="form.phone.$error.required && submitted">
          电话为必填内容
        </p>
      </div>

      <div class="form-group" ng-class="{ 'has-success': form.email.$valid && submitted,
                                          'has-error': form.email.$invalid && submitted }">
        <label>邮箱</label>

        <input type="email" name="email" class="form-control" ng-model="user.email"
               required
               mongoose-error/>
        <p class="help-block" ng-show="form.email.$error.email && submitted">
          这不像是有效的邮箱地址
        </p>
        <p class="help-block" ng-show="form.email.$error.required && submitted">
          你的邮箱地址是？?
        </p>
        <p class="help-block" ng-show="form.email.$error.mongoose">
          {{ errors.email }}
        </p>
      </div>

      <div class="form-group" ng-class="{ 'has-success': form.department.$valid && submitted,
                                          'has-error': form.department.$invalid && submitted }">
        <label>部门</label>
        <select name="department" class="form-control" ng-model="user.department" ng-options="department as department.name for department in departments" required>
          <option value="">---- 选择所属部门 ----</option>
        </select>
        <p class="help-block">
          <a ui-sref="app.admin-departments">没有想要选择的部门？</a>
        </p>
        <p class="help-block" ng-show="form.department.$error.required && submitted">
          部门为必填内容.
        </p>
      </div>

      <div class="form-group" ng-class="{ 'has-success': form.role.$valid && submitted,
                                          'has-error': form.role.$invalid && submitted }">
        <label>职位</label>
        <select name="role" class="form-control" ng-model="user.role" required>
          <option value="">---- 选择所属职位 ----</option>
          <option value="普通员工">普通员工</option>
          <option value="部门主管">部门主管</option>
          <option value="总经理">总经理</option>
        </select>
        <p class="help-block" ng-show="form.role.$error.required && submitted">
          职位为必填内容.
        </p>
      </div>

      <div class="form-group" ng-class="{ 'has-success': form.registed_at.$valid,
                                              'has-error': form.registed_at.$invalid && submitted }">
        <label for="registed_at">*入职日期</label>
        <input type="text" id="registed_at" class="form-control" datepicker-popup="yyyy-MM-dd" is-open="opened" ng-focus="opened = true" name="registed_at" ng-model="user.registed_at" datepicker-options="dateOptions" ng-required="true" show-weeks="false" show-button-bar="false" toggle-weeks-text="周" current-text="今天" clear-text="清除" close-text="确定" />
        <p class="help-block" ng-show="form.start_date.$error.required">
          <span class="text-danger"> 入职日期 为必填项目</span>
        </p>
      </div>

      <div class="form-group" ng-class="{ 'has-success': form.password.$valid && submitted,
                                          'has-error': form.password.$invalid && submitted }">
        <label>密码</label>

        <input type="password" name="password" class="form-control" ng-model="user.password"
               ng-minlength="3"
               required
               mongoose-error/>
        <p class="help-block"
           ng-show="(form.password.$error.minlength || form.password.$error.required) && submitted">
          密码至少在三位数.
        </p>
        <p class="help-block" ng-show="form.password.$error.mongoose">
          {{ errors.password }}
        </p>
      </div>

      <div>
        <button class="btn btn-inverse btn-lg btn-login" type="submit">
          添加
        </button>
      </div>

    </form>
  </section>
</div>
